package com.servlet;

import com.dao.EmployeeDao;
import com.model.Employee;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findById")
public class EmpFindByIdServlet extends HttpServlet {
    private EmployeeDao employeeDao = new EmployeeDao();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=UTF-8");
        String id = req.getParameter("id");
        Employee employee = employeeDao.selectById(Integer.parseInt(id));
        req.setAttribute("employee", employee);
        req.getRequestDispatcher("editEmp.jsp").forward(req,resp);
    }
}
